package service;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

import pojo.ArchivePojo;
import util.MybatisSessionFactory;
import dao.ArchiveDao;

public class ArchiveService {
	SqlSession sql = MybatisSessionFactory.getSqlSession();
	ArchiveDao dao = sql.getMapper(ArchiveDao.class);

	public void add(
			@Param("user_id") String user_id,
			@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		dao.add(user_id, archive_id, identity, name, gender, birthday,
				date_retire1, date_retire2, sp, fc, title, seniority);
		sql.commit();
	}

	public ArchivePojo queryid() {
		return dao.queryid();
	}

	public List<ArchivePojo> queryall(
			@Param("user_id") String user_id,
			@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		return dao.queryall(user_id, archive_id, identity, name, gender,
				birthday, date_retire1, date_retire2, sp, fc, title, seniority);

	}

	public List<ArchivePojo> queryNumber(
			@Param("archive_id") String archive_id,
			@Param("user_id") String user_id) {
		return dao.queryNumber(archive_id, user_id);

	}

	public List<ArchivePojo> queryOneById(String id) {
		return dao.queryOneById(id);

	}

	public List<ArchivePojo> queryDecide(
			@Param("archive_id") String archive_id,
			@Param("identity") String identity) {
		return dao.queryDecide(archive_id, identity);

	}

	public void update(@Param("id") String id,
			@Param("user_id") String user_id,
			@Param("archive_id") String archive_id,
			@Param("identity") String identity, @Param("name") String name,
			@Param("gender") String gender, @Param("birthday") String birthday,
			@Param("date_retire1") String date_retire1,
			@Param("date_retire2") String date_retire2, @Param("sp") String sp,
			@Param("fc") String fc, @Param("title") String title,
			@Param("seniority") String seniority) {
		dao.update(id, user_id, archive_id, identity, name, gender, birthday,
				date_retire1, date_retire2, sp, fc, title, seniority);
		sql.commit();
	}

	public List<ArchivePojo> queryCount(String user_id) {
		return dao.queryCount(user_id);

	}

	public List<ArchivePojo> queryBrowse(String user_id) {
		return dao.queryBrowse(user_id);

	}

	public List<ArchivePojo> queryRecentlyAdd(String user_id) {
		return dao.queryRecentlyAdd(user_id);

	}

}
